import {ref} from 'vue'
import {defineStore} from 'pinia'

//主题配置
export const useAdminStore = defineStore('admin', () => {
    const admin = ref({
        nickname: undefined,
        avatar: undefined,
        isSupperAdmin: undefined,
        token: undefined,
        roles: [],
        menus:[],
        permissions: []
    })

    const setAdmin = (data) => {
        admin.value = data
    }

    const resetAdmin = () => {
        admin.value = {
            nickname: undefined,
            avatar: undefined,
            isSupperAdmin: undefined,
            token: undefined,
            roles: [],
            menus:[],
            permissions: [],
        }
    }

    //获取菜单
    const getMenu = () => {
        return admin.value.menus
    }

    return {admin, setAdmin,resetAdmin,getMenu}
}, {persist: true})
